/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package co.edu.senaclem.persistencia;

import co.edu.senaclem.modelo.Fichatitulacion;
import co.edu.senaclem.modelo.Novedad;
import co.edu.senaclem.modelo.Seguimiento;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author DILOVE
 */
@Stateless
public class NovedadDAO implements INovedadDAO {
    @PersistenceContext
    private EntityManager entityManager;
    
    @Override
    public void registrar(Novedad novedad) throws Exception {
        try {
            entityManager.persist(novedad);
        } catch (RuntimeException e) {
            throw e;
        }
    }

    @Override
    public List<Novedad> consultar() throws Exception {
        try {
            String jpql="Select n From Novedad n";
            Query query = entityManager.createQuery(jpql);
            return query.getResultList();
        } catch (RuntimeException e) {
            throw e;
        }
    }

    @Override
    public Novedad consultarPorNumero(Integer numeroNovedad) throws Exception {
         try {
            return entityManager.find(Novedad.class, numeroNovedad);
        } catch (RuntimeException e) {
            throw e;
        }
    }
}
